#include <my_header.h>
#include <mysql/mysql.h>

int main()
{
    MYSQL * mysql = mysql_init(NULL);
    MYSQL * ret = mysql_real_connect(mysql,"localhost","root","123","netdisk",0,NULL,0);
    if(ret == NULL){
        fprintf(stderr,"mysql_real_connect:%s\n",mysql_error(mysql));
        printf("线程退出再监听\n");
    }
    char sql[1024] = {0};
    char username[] = "maolin";
    char prev_path[] = "/dir1";
    sprintf(sql,"select * from usrfile where username = '%s' and path = '%s' ;",username,prev_path);
    int qret = mysql_query(mysql,sql);
    if(qret != 0){
        fprintf(stderr,"mysql_query :%s\n",mysql_error(mysql));
        printf("0\n");
        return 0;
    }
    MYSQL_RES * table = mysql_store_result(mysql);
    if(table == NULL && mysql_field_count(mysql) == 0){
        printf("0\n");
        return 0;
    }
    
    MYSQL_ROW row = mysql_fetch_row(table);
    if( strcmp(row[0],"2") == 0){
        printf("row[6]:%s\n",row[6]);
        printf("1\n");
    }else{
        printf("0\n");
    } 
   // bzero(sql,sizeof(sql));
   // char type = 'f';
   // sprintf(sql,"insert into usrfile (filename,username,parent_id,path,type) values ('%s','%s',%s,'%s','%c') ;","sir","maolin","3","/dir2/sir",'f');
  //  qret = mysql_query(mysql,sql);
   // if(qret != 0){
   //     fprintf(stderr,"mysql_query 3:%s\n",mysql_error(mysql));
  //      return 0;
  //  }

    return 0;



}

